package com.zjlp.seproject.mapper;

import com.zjlp.seproject.pojo.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
@Mapper
public interface CommentMapper {
    List<Comment> selectAll();

    int deleteByPrimaryKey(Integer id);

    int insert(Comment record);

    Comment selectByPrimaryKey(Integer id);

    int updateByPrimaryKey(Comment record);

    @Update("insert into comment(uid, subjectid, comment, time) values(#{uid}, #{subjectid}, #{comment}, #{time})")
    Integer addComment(Comment comment);

    @Select("select c.id, u.username, c.comment, c.time, u.avatar from comment c, user u " +
            "where subjectid = #{id} and c.uid = u.id")
    List<CommentDetails> getComment(Integer id);
}